 <?php
$pathdir="/var/www/plugmatter/";
$nameArchive="MyArchive2.zip";
$zip=new ZipArchive;
if($zip->open($nameArchive,ZipArchive::CREATE)===TRUE){
  $dir=opendir($pathdir);
  $zip->extractTo('/var/www/zipper/');
  while ($file=readdir($dir)) {
    echo $file;
    if(is_file($pathdir.$file)){
    	//echo $pathdir;
      $zip->addFile($pathdir.$file,$file);
      //rename($pathdir.$file, 'zipper/'.$file);
    }
  }
  $zip->close();
  echo "archivated succesful";
}
else echo "error";

?>